package com.bjsxt.livegoods.dao.order;

import com.bjsxt.livegoods.entity.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;

import java.util.List;

public class OrderDaoImpl implements OrderDao{

    @Autowired
    private MongoTemplate mongoTemplate;

    @Override
    public void insertOrder(Order order) {
        mongoTemplate.insert(order);
    }

    @Override
    public List<Order> findOrders(Query query) {
        return mongoTemplate.find(query,Order.class);
    }

    @Override
    public void updateOrder(Query query, Update update) {
        mongoTemplate.updateFirst(query,update,Order.class);
    }

    public MongoTemplate getMongoTemplate() {
        return mongoTemplate;
    }

    public void setMongoTemplate(MongoTemplate mongoTemplate) {
        this.mongoTemplate = mongoTemplate;
    }
}
